from .const import *


def judge_guide_shoot1(agent, obj_id):
    """
    吴欣娟 2022.10.23
    引导射击基础条件判断
    :param agent:
    :param obj_id:
    :return: True False
    """
    bop = agent.get_bop(obj_id)
    if bop['sub_type'] == BopSubType.UGV:
        if bop["guide_ability"] and bop["car"]:  # 确保算子是无人战车，引导射击能力，有从属的重型战车
            car_bop = agent.get_bop[bop["car"]]
            if 73 in car_bop["carry_weapon_ids"]:  # 确保重型战车携带有重型导弹
                if car_bop["remain_bullet_nums"][100] > 0:  # 确保有剩余的重型导弹
                    return True
    return False


def judge_unequal_hurt(agent, obj_id):
    """
    吴欣娟 2022/10/24
    判断是否遭遇不对等打击或无人机
    """
    bop = agent.get_bop(obj_id)
    if bop['sub_type'] == BopSubType.UGV:  # 确保是无人战车
        if bop['see_enemy_bop_ids']:  # 判断看见的敌人中是否有无人机
            for enemy in bop['see_enemy_bop_ids']:
                enemy_bop = agent.get_bop(enemy)
                if enemy_bop:
                    if enemy_bop['sub_type'] == BopSubType.Drone:
                        return True
        for judge_message in agent.observation["jm_points"]:  # 判断是否遭遇间瞄射击
            if judge_message['pos'] == bop['cur_hex']:
                return True
    return False




